stash = qmenu.item("&Mark", StashMe, "Marking is a preliminary for the `Reorganize Tree' operations, which help to (re)organize the group-structure in the tree-view.\n\nFor example you can mark a group, and then later insert a selected entity into it, or mark an entity, and later insert it into or over (in the treeview) the selected group.\n\nReorganize Tree operations that can't be applied sensibly to the selected and marked objects are supposed to be greyed out; if they aren't it's a bug.")
restrict = qmenu.item("&Restrict", RestrictByMe, "|Restricts selections to being within this.\n\nGood if for example you want to work on the details of a desk or staircase for a while.")
zoom = qmenu.item("&Zoom", ZoomToMe, "Fill the views with selected.")
if restricted:
select.state=qmenu.disabled
if current.type == ":e" or current.type == ":f":
restrict.state = qmenu.disabled
item = qmenu.popup(name,[zoom,select,restrict,stash],None,"|This is the name of some group or brush entity that contains what you have selected.\n\nLook at its submenu for stuff you can do!\n\nIf there's a bar in the menu, then the `Restrict Selections' menu item is checked, and you can only select stuff above the bar.")
item.menuicon = current.geticon(1)
item.object = current
stash.object = select.object = restrict.object = zoom.object = current
# restrict.object = current
return item
#
# For an object o, uses the parentpopupitems function to
# construct a menu of popups, one for each object over o.
list = buildParentPopupList(o,parentpopupitems, editor)
if list == []:
parentpopup.state=qmenu.disabled
else:
parentpopup.items = list
return parentpopup
#
# This makes a parent popup item for navigating the tree
# above the selected item. Imitate in other files to
# make more, with replacement for navTreePopupItems.
#
def navTreePopup(o,editor):
parentSelPop = qmenu.popup("&Navigate Tree", hint = "|The submenu that appears comprises the currently selected object at the top, and below it, the map objects (polys, groups & brush entities) that are above it in the group tree-structure.\n\nIf you put the cursor over one of these, you will get a further sub-menu with relevant commands to select from.")
quarkpy.mapoptions.items.append(quarkpy.mapoptions.toggleitem("Look and Zoom in 3D views", "3Dzoom", (1,1),
hint="|Look and Zoom in 3D views:\n\nIf this menu item is checked, it will zoom in and center on the selection(s) in all of the 3D views when the 'Zoom to selection' button on the 'Selection Toolbar' is clicked.\n\nIf a face is selected and the 'Shift' key is held down, it will look at the other side of the face and strive to center it in the view.\n\nIf this menu item is unchecked, it will only look in the selection(s) direction from the current camera position.|intro.mapeditor.menu.html#optionsmenu"))
# (like tagging, maybe should be an extension of tagging)
#
def stashitem(o):
item = qmenu.item('Mark '+types[o.type], StashMe, "mark for tree-restructuring")
item.object = o
return item
def StashMe(m):
editor = mapeditor()
if editor is None: return
editor.marker = m.object
def getstashed(e):
try:
return e.marker
except (AttributeError) : return None
def clearstashed(e):
try:
del e.marker
except (AttributeError) : pass
#
# ------------- restrictor -----------
# (like stash, for marking but just for restricting
# the selection)
#
def getrestrictor(e):
try:
return e.restrictor
except (AttributeError) : return None
#
# ---------- insertinto ---------
#
def insert_ok(insertee, goal):
if goal is None or insertee is None:
return 0
if insertee.type is ":f" and (goal.type is ":p") or (goal.type is ":g"):
return 1
if insertee.name=="worldspawn:b" or not (goal.type==":g" or goal.type==":b"):
return 0
return 1
def insertinto(o):
"inserts marked into selected"
editor=mapeditor()
marked = getstashed(editor)
if not insert_ok(marked, o):
item = qmenu.item("Insert marked into this",InsertIntoMe,"Mark something to insert it somewhere")
item.state=qmenu.disabled
return item
text = "Insert "+`marked.shortname`+" into this"
item = qmenu.item(text,InsertIntoMe,"Insert what you marked into this")
item.object = o
item.text = text
item.marked = marked
return item
def InsertIntoMe(m):
undo = quarkx.action()
undo.move(m.marked, m.object)
mapeditor().ok(undo, m.text)
def insertover(o):
"inserts marked over selected (o)"
editor=mapeditor()
marked = getstashed(editor)
if not insert_ok(marked, o.treeparent):
item = qmenu.item("Insert marked over this",InsertOverMe,"Mark something to insert it places")
item.state=qmenu.disabled
return item
text = "Insert "+`marked.shortname`+" over this"
item = qmenu.item(text,InsertOverMe,"|Insert what you marked over the position of this in the tree-view")
item.object = o
item.marked = marked
item.text = text
return item
def InsertOverMe(m):
undo = quarkx.action()
undo.move(m.marked, m.object.parent, m.object)
mapeditor().ok(undo, m.text)
def insertme(o):
"inserts this into marked"
editor=mapeditor()
marked = getstashed(editor)
if not insert_ok(o,marked):
item = qmenu.item("Insert this into marked",InsertMeInto,"Mark something to insert stuff into it")
item.state=qmenu.disabled
return item
text = "Insert this into "+`marked.shortname`
item = qmenu.item(text,InsertMeInto,"")
item.object = o
item.text = text
item.marked = marked
return item
def InsertMeInto(m):
undo = quarkx.action()
undo.move(m.object, m.marked)
mapeditor().ok(undo, m.text)
def facelift(o):
"returns a menu item for lifting face into marked group"
editor = mapeditor()
marked = getstashed(editor)
help = "|Lifts face to marked group, removing coplanar faces within that group."
item = qmenu.item("&Lift to marked group",LiftMe,help)
if marked is None:
item.state = qmenu.disabled
item.hint = item.hint+"\n\nFor this item to be enabled, there must be a marked group containing the face (Navigate tree|<some containing group>|Mark)."
return item
if not checktree(marked,o):
item.state = qmenu.disabled
item.hint = item.hint+"\n\nFor this item to be enabled, the marked group must contain the face"
return item
item.marked = marked
item.object=o
return item
def LiftMe(m):
o=m.object
list = m.marked.findallsubitems("",":f")
undo = quarkx.action()
undo.move(m.object, m.marked)
for face in list:
if faceutils.coplanar(o, face) and o != face:
undo.exchange(face,None)
mapeditor().ok(undo, m.text)
###################################
#
# right-mouse menus for faces. Messes up selected brush
#
###################################
exttext = "|Extends the selection from this face to all the faces that make a single unbroken sheet with this one.\n\nSo you can for example move the bottom of a ceiling brush, and have the tops of the wall brushes follow, if they're on the same plane as the bottom of the ceiling.\n\nYou can also Link the selected faces, so that all of them can be snapped to the position of one of them with one click.|intro.mapeditor.menu.html#invertface"
def extendtolinked(editor,o):
"extend the selection to the linked faces"
item = qmenu.item("to &Linked faces",ExtendToLinkedClick,"Extend Selection to Linked Faces")
meninvertfacesel = quarkpy.qmenu.item("&Invert Face Selection", invertFaceSelClick, "|Invert Face Selection:\n\nThis is for polys containing faces that are currently selected, deselect these and select the other, currently unselected, faces.|intro.mapeditor.menu.html#invertface")
menrestsel = quarkpy.qmenu.item("&Restrict to Selection", RestSelClick,"|Restrict to Selection:\n\nRestrict selections to within the current restrictor group, if any, which you can set with by clicking `Containing Groups I Some Item I Restrict' on the right mouse menu for polys, etc.|intro.mapeditor.menu.html#invertface")
menextsel = quarkpy.qmenu.item("&Extend Selection from Face", ExtendSelClick, exttext)
mennosel = quarkpy.qmenu.item("No Selection in Map Views", NoSelClick, "|No Selection in Map Views:\n\nWhen this menu item is checked, selection in the map views is prevented.\n\nThis is useful when touring with the 3d viewer, to prevent selecting things accidentally.|intro.mapeditor.menu.html#optionsmenu");
menunrestrict = quarkpy.qmenu.item("&Unrestrict Selection",UnrestrictClick,"|Unrestrict Selection:\n\nWhen selection is restricted (see the Containing Groups right-mouse menu), clicking on this will unrestrict the selection & restore things to normal.|intro.mapeditor.menu.html#invertface")
zoomItem = qmenu.item("&Zoom to selection", ZoomToMe, "|Zoom to selection:\n\nZooms the map views in to the selection.|intro.mapeditor.menu.html#invertface")
def menunrestrictenable(editor):
if getrestrictor(editor) is None:
menunrestrict.state=qmenu.disabled
else:
menunrestrict.state=qmenu.normal
for menitem, keytag in [(menextsel, "Extend Selection"),
(menunrestrict, "Unrestrict Selection"),
(menrestsel, "Restrict to Selection"),
(browseItem, "Browse Multiple Selection"),
(meninvertfacesel, "Invert Face Selection"),
(zoomItem, "Zoom to Selection")]:
MapHotKey(keytag,menitem,quarkpy.mapselection)
#
# -- selection menu items
#
stashItem = qmenu.item("&Mark selection", StashMe, "|Mark selection:\n\nThis command designates the selection as a special element for other (mostly somewhat advanced) commands, such as 'Lift face to marked group' on the face RMB, or the 'Reorganize Tree' commands on various map object RMB's.|intro.mapeditor.menu.html#invertface")
clearItem = qmenu.item("Clear Mark", ClearMarkClick, "|Clear Mark:\n\nThis cancels the Mark selection.|intro.mapeditor.menu.html#invertface")